<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.2.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="sha256-XOqroi11tY4EFQMR9ZYwZWKj5ZXiftSx36RRuC3anlA=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"example.com","root":"/","images":"/images","scheme":"Muse","darkmode":false,"version":"8.20.0","exturl":false,"sidebar":{"position":"left","width_expanded":320,"width_dual_column":240,"display":"post","padding":18,"offset":12},"copycode":{"enable":false,"style":null},"fold":{"enable":false,"height":500},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="epsilon-约束方法是一种多目标优化算法，借助它我们也可以使用Gurobi等求解工具求解多目标优化算法，且其求解效果比加权法更好。">
<meta property="og:type" content="article">
<meta property="og:title" content="epsilon-约束方法">
<meta property="og:url" content="http://example.com/2024/05/06/epsilon-%E7%BA%A6%E6%9D%9F%E6%96%B9%E6%B3%95/index.html">
<meta property="og:site_name" content="TUUG个人主页">
<meta property="og:description" content="epsilon-约束方法是一种多目标优化算法，借助它我们也可以使用Gurobi等求解工具求解多目标优化算法，且其求解效果比加权法更好。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://example.com/images/image-20240304112349257.png">
<meta property="og:image" content="http://example.com/images/image-20240304112820159.png">
<meta property="og:image" content="http://example.com/images/image-20240304112906514.png">
<meta property="og:image" content="http://example.com/images/image-20240304112938975.png">
<meta property="article:published_time" content="2024-05-06T03:24:54.292Z">
<meta property="article:modified_time" content="2024-05-06T12:26:45.149Z">
<meta property="article:author" content="TUUG">
<meta property="article:tag" content="精确优化方法">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://example.com/images/image-20240304112349257.png">


<link rel="canonical" href="http://example.com/2024/05/06/epsilon-%E7%BA%A6%E6%9D%9F%E6%96%B9%E6%B3%95/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"http://example.com/2024/05/06/epsilon-%E7%BA%A6%E6%9D%9F%E6%96%B9%E6%B3%95/","path":"2024/05/06/epsilon-约束方法/","title":"epsilon-约束方法"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>epsilon-约束方法 | TUUG个人主页</title>
  








  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css">
<!-- hexo injector head_end end --><link rel="alternate" href="/atom.xml" title="TUUG个人主页" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">TUUG个人主页</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">成为你想成为的人</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li><li class="menu-item menu-item-schedule"><a href="/schedule/" rel="section"><i class="fa fa-calendar fa-fw"></i>日程表</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#varepsilon-%E7%BA%A6%E6%9D%9F%E6%96%B9%E6%B3%95%EF%BC%88%E8%BF%99%E6%A0%B7GUROBI%E4%B9%9F%E8%83%BD%E8%A7%A3%E5%A4%9A%E7%9B%AE%E6%A0%87%E9%97%AE%E9%A2%98%E4%BA%86%EF%BC%81%EF%BC%89"><span class="nav-number">1.</span> <span class="nav-text">$\varepsilon$-约束方法（这样GUROBI也能解多目标问题了！）</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#varepsilon-%E7%BA%A6%E6%9D%9F%E6%96%B9%E6%B3%95%E7%AE%80%E4%BB%8B"><span class="nav-number">1.1.</span> <span class="nav-text">$\varepsilon$-约束方法简介</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%BF%87%E7%A8%8B"><span class="nav-number">1.2.</span> <span class="nav-text">过程</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BE%8B%E5%AD%90"><span class="nav-number">1.3.</span> <span class="nav-text">例子</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8F%82%E8%80%83%E6%96%87%E7%8C%AE"><span class="nav-number">1.4.</span> <span class="nav-text">参考文献</span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="TUUG"
      src="/images/%E9%AB%98%E8%BE%BE%E5%A4%B4%E5%83%8F.png">
  <p class="site-author-name" itemprop="name">TUUG</p>
  <div class="site-description" itemprop="description">心有所向，无问西东</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">4</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">4</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/John-start" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;John-start" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="/tr666666@qq.com" title="E-Mail → tr666666@qq.com" rel="noopener me"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://blog.csdn.net/faithful1" title="CSDN → https:&#x2F;&#x2F;blog.csdn.net&#x2F;faithful1" rel="noopener me" target="_blank"><i class="fab fa-csdn fa-fw"></i>CSDN</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
    <div class="sidebar-inner sidebar-blogroll">
      <div class="links-of-blogroll animated">
        <div class="links-of-blogroll-title"><i class="fa fa-globe fa-fw"></i>
          链接
        </div>
        <ul class="links-of-blogroll-list">
            <li class="links-of-blogroll-item">
              <a href="https://blog.csdn.net/faithful1" title="https:&#x2F;&#x2F;blog.csdn.net&#x2F;faithful1" rel="noopener" target="_blank">CSDN</a>
            </li>
        </ul>
      </div>
    </div>
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2024/05/06/epsilon-%E7%BA%A6%E6%9D%9F%E6%96%B9%E6%B3%95/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/%E9%AB%98%E8%BE%BE%E5%A4%B4%E5%83%8F.png">
      <meta itemprop="name" content="TUUG">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="TUUG个人主页">
      <meta itemprop="description" content="心有所向，无问西东">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="epsilon-约束方法 | TUUG个人主页">
      <meta itemprop="description" content="epsilon-约束方法是一种多目标优化算法，借助它我们也可以使用Gurobi等求解工具求解多目标优化算法，且其求解效果比加权法更好。">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          epsilon-约束方法
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>
      

      <time title="创建时间：2024-05-06 11:24:54 / 修改时间：20:26:45" itemprop="dateCreated datePublished" datetime="2024-05-06T11:24:54+08:00">2024-05-06</time>
    </span>

  
    <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv">
      <span class="post-meta-item-icon">
        <i class="far fa-eye"></i>
      </span>
      <span class="post-meta-item-text">阅读次数：</span>
      <span id="busuanzi_value_page_pv"></span>
    </span>
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>4.2k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>8 分钟</span>
    </span>
</div>

            <div class="post-description">epsilon-约束方法是一种多目标优化算法，借助它我们也可以使用Gurobi等求解工具求解多目标优化算法，且其求解效果比加权法更好。</div>
        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><h1 id="varepsilon-约束方法（这样GUROBI也能解多目标问题了！）"><a href="#varepsilon-约束方法（这样GUROBI也能解多目标问题了！）" class="headerlink" title="$\varepsilon$-约束方法（这样GUROBI也能解多目标问题了！）"></a>$\varepsilon$-约束方法（这样GUROBI也能解多目标问题了！）</h1><p>一般解决多目标优化问题的算法都是NSGA-II算法、MOEA-D算法等多目标智能算法。采用Gurobi精确求解的方法往往难以求出pareto最优解，只能通过对多个目标进行加权的方式求解。今天我们学习一种方法，借助它我们也可以使用Gurobi等求解工具求解多目标优化算法，且其求解效果比加权法更好。</p>
<p><img src="/../images/image-20240304112349257.png"></p>
<hr>
<h2 id="varepsilon-约束方法简介"><a href="#varepsilon-约束方法简介" class="headerlink" title="$\varepsilon$-约束方法简介"></a>$\varepsilon$-约束方法简介</h2><p>$\varepsilon$-约束方法是一种多目标优化算法。它基于约束优化的思想，通过引入一个参数$\varepsilon$来控制目标函数的权重，从而保证满足约束条件的前提下，寻找到最优解的近似解集。</p>
<p>通过选取一个主目标函数，将其余目标函数转化为约束，从而计算每个子优化目标，得到帕累托解集。</p>
<h2 id="过程"><a href="#过程" class="headerlink" title="过程"></a>过程</h2><p>针对一个多目标优化问题：<br>$$<br>min {f_1(x),f_2(x),f_3(x)} \<br>h(x)&#x3D;0 \<br>g(x)\leq 0<br>$$</p>
<p>使用ε约束算法转化问题为：<br>$$<br>min f_1(x) \<br>f_2(x)\leq \epsilon_2,\cdots,f_n(x)\leq\epsilon_n \<br>h(x) &#x3D; 0 \<br>g(x) \leq 0<br>$$<br>其中的每个参数$\epsilon_2,\epsilon_3,\cdots,\epsilon_n$通过计算payoff矩阵得到。</p>
<p>payoff的计算过程：</p>
<ol>
<li><p>求解出第i个目标函数的最优值$f_i(x_i^*)$，得到其最优解$x_i^*$；</p>
</li>
<li><p>将$x_i^*$代入其他目标函数得到${f_1(x_i^*),f_2(x_i^*),\cdots,f_n(x_i^*)}$；</p>
</li>
<li><p>对全部目标函数按照上述流程求解，得到payoff table矩阵如下：<br>$$<br>\begin{bmatrix}<br>f_1(x_1^*) &amp; \cdots &amp; f_i(x_1^*) &amp;\cdots &amp; f_n(x_1^*)\<br>\vdots&amp; \ddots &amp;&amp;&amp; \vdots\<br>f_1(x_i^*) &amp; \cdots &amp; f_i(x_i^*) &amp;\cdots &amp; f_n(x_i^*)\<br>\vdots&amp; \ddots&amp; &amp; &amp; \vdots \<br>f_1(x_n^*) &amp; \cdots &amp; f_i(x_n^*) &amp;\cdots &amp; f_n(x_n^*)\<br>\end{bmatrix}<br>$$</p>
</li>
</ol>
<p>该方法本质上与网格搜索法相同。得到了payoff矩阵之后，可以求出每个目标的最优值和最劣值（就是每个目标维度的最大和最小值）。记为最优解(U)和最劣解(SN)$f_i^U &#x3D; f_i(x_i^*)$,$f_i^{SN} &#x3D; f_i(x_j^*)$。</p>
<p>选择一个主目标函数$f_k(x)$。</p>
<p>对于主目标函数外的目标函数$f_{i}(x)$，设置一个网格化分数$q_{ij}∈{1,2,\cdots,q_i,max} $。</p>
<p>由此计算除了主目标函数外的其余目标函数的ε约束如下：<br>$$<br>ϵ_{ij}&#x3D;f_i^{SN}−\frac{(f_i^{SN}−f_i^{U})}{q_{ij}}⋅j \qquad j&#x3D;1,2,…,q_{i,max}<br>$$<br>得到每个优化子问题如下：<br>$$<br>min f_k(x)\<br>s.t. \qquad f_1(x)\leq \epsilon_{1j},f_2(x)\leq \epsilon_{1l},f_n(x)\leq \epsilon_{1m},h(x)&#x3D;0,g(x)\leq0<br>$$<br>其中,$j&#x3D;1,2,\cdots,q_{1,max};l&#x3D;1,2,\cdots,q_{2,max};\cdots;m&#x3D;1,2,\cdots,q_{n,max};$</p>
<p>每次求出一个最优解，若在可行域内则加入帕累托解集，若不在可行域内则丢弃。</p>
<h2 id="例子"><a href="#例子" class="headerlink" title="例子"></a>例子</h2><p>$$<br>min \quad f_1(x) &#x3D; x_2-x_1 \<br>min \quad f_2(x) &#x3D; x_1+x_2 \<br>s.t. \qquad x_1^2 - 2x_1 + 1 \leq x_2 \<br>0 \leq x_1 \leq 1 \<br>0 \leq x_2 \leq 1<br>$$</p>
<p>使用python+gurobi求解代码如下：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#!/usr/bin/env python</span></span><br><span class="line"><span class="comment"># -*- coding: utf-8 -*-</span></span><br><span class="line"><span class="comment"># @Time    : 2024/3/3 11:35</span></span><br><span class="line"><span class="comment"># @Author  : TUUG</span></span><br><span class="line"><span class="comment"># @Email   : tr6666666@qq.com</span></span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="keyword">from</span> matplotlib <span class="keyword">import</span> pyplot <span class="keyword">as</span> plt</span><br><span class="line"><span class="keyword">import</span> gurobipy <span class="keyword">as</span> gp</span><br><span class="line"></span><br><span class="line"><span class="keyword">def</span> <span class="title function_">f1</span>(<span class="params">constraint=<span class="literal">None</span></span>):</span><br><span class="line">    model = gp.Model()</span><br><span class="line">    x1 = model.addVar(name=<span class="string">&quot;X1&quot;</span>,vtype=gp.GRB.CONTINUOUS,lb=<span class="number">0</span>,ub=<span class="number">1</span>)</span><br><span class="line">    x2 = model.addVar(name=<span class="string">&quot;X2&quot;</span>,vtype=gp.GRB.CONTINUOUS,lb=<span class="number">0</span>,ub=<span class="number">1</span>)</span><br><span class="line">    <span class="comment"># 添加约束</span></span><br><span class="line">    model.addConstr(x1*x1-<span class="number">2</span>*x1+<span class="number">1</span>&lt;=x2)</span><br><span class="line">    <span class="keyword">if</span> constraint <span class="keyword">is</span> <span class="keyword">not</span> <span class="literal">None</span>:</span><br><span class="line">        model.addConstr(x1+x2&lt;=constraint)</span><br><span class="line">    <span class="comment"># 定义目标函数</span></span><br><span class="line">    model.setObjective(x2-x1, sense = gp.GRB.MINIMIZE)</span><br><span class="line">    model.update()</span><br><span class="line">    <span class="comment"># 求解模型</span></span><br><span class="line">    model.optimize()</span><br><span class="line">    <span class="keyword">return</span> x1.x,x2.x</span><br><span class="line">    </span><br><span class="line"><span class="keyword">def</span> <span class="title function_">f2</span>():</span><br><span class="line">    <span class="comment"># 创建模型</span></span><br><span class="line">    m2 = gp.Model(<span class="string">&quot;f2_optimization&quot;</span>)</span><br><span class="line">    <span class="comment"># 定义变量</span></span><br><span class="line">    x1 = m2.addVar(name=<span class="string">&quot;X1&quot;</span>,vtype=gp.GRB.CONTINUOUS,lb=<span class="number">0</span>,ub=<span class="number">1</span>)</span><br><span class="line">    x2 = m2.addVar(name=<span class="string">&quot;X2&quot;</span>,vtype=gp.GRB.CONTINUOUS,lb=<span class="number">0</span>,ub=<span class="number">1</span>)</span><br><span class="line">    <span class="comment"># 添加约束</span></span><br><span class="line">    m2.addConstr(x1*x1-<span class="number">2</span>*x1+<span class="number">1</span>&lt;=x2)</span><br><span class="line">    <span class="comment"># model.addConstr(x2-x1&gt;=cons)</span></span><br><span class="line">    <span class="comment"># 定义目标函数</span></span><br><span class="line">    m2.setObjective(x2+x1, sense = gp.GRB.MINIMIZE)</span><br><span class="line">    <span class="comment"># 求解模型</span></span><br><span class="line">    m2.optimize()</span><br><span class="line">    <span class="keyword">return</span> x1.x,x2.x</span><br><span class="line"></span><br><span class="line">f11,f12 = f1()</span><br><span class="line">f21,f22 = f2()</span><br><span class="line">f1_min = f12-f11</span><br><span class="line">f2_max = f11+f12</span><br><span class="line">f2_min = f21+f22</span><br><span class="line">f1_max = f22-f21</span><br><span class="line"><span class="built_in">print</span>(<span class="string">&#x27;--------------&#x27;</span>)</span><br><span class="line"><span class="built_in">print</span>(f2_min,f2_max)</span><br><span class="line">soultion_pool = []</span><br><span class="line">q_n =<span class="number">10</span></span><br><span class="line"><span class="keyword">for</span> q <span class="keyword">in</span> <span class="built_in">range</span>(q_n):</span><br><span class="line">    constraint = f2_max-(f2_max-f2_min)/q_n*q</span><br><span class="line">    <span class="comment"># constraint = np.linspace(f2_min,f2_max,10)[q]</span></span><br><span class="line">    f11,f12 = f1(constraint=constraint)</span><br><span class="line">    soultion_pool.append([f12-f11,f11+f12])</span><br><span class="line"><span class="built_in">print</span>(soultion_pool)</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line">pareto_front_solutions = np.array(soultion_pool)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 绘制 Pareto 前沿解</span></span><br><span class="line">plt.scatter(pareto_front_solutions[:, <span class="number">0</span>], pareto_front_solutions[:, <span class="number">1</span>], label=<span class="string">&#x27;Pareto Front&#x27;</span>)</span><br><span class="line">plt.xlabel(<span class="string">&#x27;f1(x)&#x27;</span>)</span><br><span class="line">plt.ylabel(<span class="string">&#x27;f2(x)&#x27;</span>)</span><br><span class="line">plt.title(<span class="string">&#x27;Pareto Front for Multi-objective Optimization&#x27;</span>)</span><br><span class="line">plt.legend()</span><br><span class="line">plt.show()</span><br></pre></td></tr></table></figure>

<p>求解结果展示如下</p>
<p>网格化分数取10时：</p>
<p><img src="/../images/image-20240304112820159.png"></p>
<p>网格化分数取20时：</p>
<p><img src="/../images/image-20240304112906514.png"></p>
<p>网格化分数取100时：</p>
<p><img src="/../images/image-20240304112938975.png"></p>
<p>可以看到，这个方法有一个很好的性质，就是可以通过增大网格化分数来改善求解结果，使其更接近真实帕累托前沿。如果求解时间过长可以减小网格化分数来缩短求解时间。</p>
<h2 id="参考文献"><a href="#参考文献" class="headerlink" title="参考文献"></a>参考文献</h2><p>[1] Ismail-Yahaya A, Messac A. Effective generation of the Pareto frontier using the normal constraint method[C]&#x2F;&#x2F;40th AIAA Aerospace Sciences Meeting &amp; Exhibit. 2002: 178.</p>
<p>[2] Fan Z, Li W, Cai X, et al. An improved epsilon constraint-handling method in MOEA&#x2F;D for CMOPs with large infeasible regions[J]. Soft Computing, 2019, 23: 12491-12510.</p>
<p>[3] Yang Z, Cai X, Fan Z. Epsilon constrained method for constrained multi-objective optimization problems: some preliminary results[C]&#x2F;&#x2F;Proceedings of the companion publication of the 2014 annual conference on genetic and evolutionary computation. 2014: 1181-1186.</p>
<p>[4]  <a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_44786238/article/details/126068290">【多目标规划问题求解】ε-约束算法_约束法多目标规划问题求解-CSDN博客</a></p>

    </div>

    
    
    

    <footer class="post-footer">
          <div class="reward-container">
  <div>请我一杯咖啡吧！</div>
  <button>
    赞赏
  </button>
  <div class="post-reward">
      <div>
        <img src="/images/wechatpay.png" alt="TUUG 微信">
        <span>微信</span>
      </div>
      <div>
        <img src="/images/alipay.png" alt="TUUG 支付宝">
        <span>支付宝</span>
      </div>

  </div>
</div>

          <div class="post-tags">
              <a href="/tags/%E7%B2%BE%E7%A1%AE%E4%BC%98%E5%8C%96%E6%96%B9%E6%B3%95/" rel="tag"># 精确优化方法</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2024/05/05/hello-world/" rel="prev" title="Hello World">
                  <i class="fa fa-angle-left"></i> Hello World
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2024/05/06/%E8%B5%84%E6%BA%90%E5%8F%97%E9%99%90%E9%A1%B9%E7%9B%AE%E8%B0%83%E5%BA%A6%E7%A8%8B%E5%BA%8FRCPSP/" rel="next" title="资源受限项目调度程序RCPSP">
                  资源受限项目调度程序RCPSP <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 
    <span itemprop="copyrightYear">2024</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">TUUG</span>
  </div>
<div class="busuanzi-count">
    <span class="post-meta-item" id="busuanzi_container_site_uv">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-item" id="busuanzi_container_site_pv">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>

<!-- 网站运行时间的设置 -->
<span id="timeDate">载入天数...</span>
<span id="times">载入时分秒...</span>
<script>
    var now = new Date();
    function createtime() {
        var grt= new Date("05/04/2024 10:00:00"); //此处修改你的建站时间或者网站上线时间
        now.setTime(now.getTime()+250);
        days = (now - grt ) / 1000 / 60 / 60 / 24; dnum = Math.floor(days);
        hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum); hnum = Math.floor(hours);
        if(String(hnum).length ==1 ){hnum = "0" + hnum;} minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum);
        mnum = Math.floor(minutes); if(String(mnum).length ==1 ){mnum = "0" + mnum;}
        seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum);
        snum = Math.round(seconds); if(String(snum).length ==1 ){snum = "0" + snum;}
        document.getElementById("timeDate").innerHTML = "本站已安全运行 "+dnum+" 天 ";
        document.getElementById("times").innerHTML = hnum + " 小时 " + mnum + " 分 " + snum + " 秒.";
    }
setInterval("createtime()",250);
</script>

    </div>
  </footer>

  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>
  <div class="sidebar-dimmer"></div>
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/schemes/muse.js"></script><script src="/js/sidebar.js"></script><script src="/js/next-boot.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>







  
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>



  <script type="text/javascript" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>
  
<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"log":false,"model":{"jsonPath":"/live2dw/assets/shizuku.model.json"},"display":{"position":"right","width":150,"height":300},"mobile":{"show":true}});</script></body>
</html>
